if (redis.call('exists', KEYS[1]) == 1) then
    local count = tonumber(redis.call('get', KEYS[1]));
    local num = tonumber(ARGV[1]);
    if (num >= 0 or (num < 0 and count + num >= 0)) then
        redis.call('incrby', KEYS[1], num);
        return 0;
    end
    return -2;
else
    return -1;
end